home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / m / infnan.man < prev    next >
Encoding:
Text File  |  1989-12-14  |  3.9 KB  |  133 lines

  1.  
  2.  
  3.  
  4. INFNAN           Mathematical Library Procedures           INFNAN
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      infnan - signals invalid floating-point operations on a VAX
  10.      (temporary)
  11.  
  12. SSYYNNOOPPSSIISS
  13.      ##iinncclluuddee <<mmaatthh..hh>>
  14.  
  15.      ddoouubbllee iinnffnnaann((iiaarrgg))
  16.      iinntt iiaarrgg;;
  17.  
  18. DDEESSCCRRIIPPTTIIOONN
  19.      At some time in the future, some of the useful properties of
  20.      the Infinities and _N_a_Ns in the IEEE standard 754 for Binary
  21.      Floating-Point Arithmetic will be simulated in UNIX on the
  22.      DEC VAX by using its Reserved Operands.  Meanwhile, the
  23.      Invalid, Overflow and Divide-by-Zero exceptions of the IEEE
  24.      standard are being approximated on a VAX by calls to a pro-
  25.      cedure _i_n_f_n_a_n in appropriate places in _l_i_b_m.  When better
  26.      exception-handling is implemented in UNIX, only _i_n_f_n_a_n among
  27.      the codes in _l_i_b_m will have to be changed.  And users of
  28.      _l_i_b_m can design their own _i_n_f_n_a_n now to insulate themselves
  29.      from future changes.
  30.  
  31.      Whenever an elementary function code in _l_i_b_m has to simulate
  32.      one of the aforementioned IEEE exceptions, it calls
  33.      infnan(iarg) with an appropriate value of _i_a_r_g.  Then a
  34.      reserved operand fault stops computation.  But _i_n_f_n_a_n could
  35.      be replaced by a function with the same name that returns
  36.      some plausible value, assigns an apt value to the global
  37.      variable _e_r_r_n_o, and allows computation to resume.  Alterna-
  38.      tively, the Reserved Operand Fault Handler could be changed
  39.      to respond by returning that plausible value, etc.  instead
  40.      of aborting.
  41.  
  42.      In the table below, the first two columns show various
  43.      exceptions signaled by the IEEE standard, and the default
  44.      result it prescribes.  The third column shows what value is
  45.      given to _i_a_r_g by functions in _l_i_b_m when they invoke
  46.      infnan(iarg) under analogous circumstances on a VAX.
  47.      Currently _i_n_f_n_a_n stops computation under all those cir-
  48.      cumstances.  The last two columns offer an alternative; they
  49.      suggest a setting for _e_r_r_n_o and a value for a revised _i_n_f_n_a_n
  50.      to return.  And a C program to implement that suggestion
  51.      follows.
  52.           IEEE      IEEE
  53.           Signal    Default   _i_a_r_g    _e_r_r_n_o             _i_n_f_n_a_n
  54.           __________________________________________________
  55.           Invalid   _N_a_N       EDOM    EDOM              0
  56.           Overflow  +_Infinity ERANGE  ERANGE            HUGE
  57.           Div-by-0  +_Infinity +_ERANGE ERANGE or EDOM    +_HUGE
  58.                     (HUGE = 1.7e38 ... nearly  2.0**127)
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 27, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. INFNAN           Mathematical Library Procedures           INFNAN
  71.  
  72.  
  73.  
  74.      ALTERNATIVE  _i_n_f_n_a_n:
  75.      ##iinncclluuddee   <<mmaatthh..hh>>
  76.      ##iinncclluuddee   <<eerrrrnnoo..hh>>
  77.      eexxtteerrnn iinntt eerrrrnnoo ;;
  78.      ddoouubbllee     iinnffnnaann((iiaarrgg))
  79.      iinntt        iiaarrgg ;;
  80.      {{
  81.                 sswwiittcchh((iiaarrgg)) {{
  82.                 ccaassee      EERRAANNGGEE:: eerrrrnnoo == EERRAANNGGEE;; rreettuurrnn((HHUUGGEE));;
  83.                 ccaassee     --EERRAANNGGEE:: eerrrrnnoo == EEDDOOMM;;   rreettuurrnn((--HHUUGGEE));;
  84.                 ddeeffaauulltt::          eerrrrnnoo == EEDDOOMM;;   rreettuurrnn((00));;
  85.                 }}
  86.      }}
  87.  
  88. SSEEEE AALLSSOO
  89.      math(3M), intro(2), signal(3).
  90.  
  91.      ERANGE and EDOM are defined in <errno.h>.  See intro(2) for
  92.      explanation of EDOM and ERANGE.
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 27, 1986                          2
  130.  
  131.  
  132.  
  133.